unit SmtpMailImpl1;

interface

uses
  Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  ComServ, StdVCL, AXCtrls, SmtpMailXControl1_TLB, SmtpMailSS ;

type
  TSmtpMailX = class(TActiveXControl, ISmtpMailX)
  private
    { Private-Deklarationen }
    FDelphiControl: TSmtpMailSS;
    FEvents: ISmtpMailXEvents;
  protected
    { Protected-Deklarationen }
    procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
    procedure EventSinkChanged(const EventSink: IUnknown); override;
    procedure InitializeControl; override;
    function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
    function Get_Cursor: Smallint; safecall;
    function Get_DoubleBuffered: WordBool; safecall;
    function Get_Enabled: WordBool; safecall;
    function Get_Visible: WordBool; safecall;
    function Get_VisibleDockClientCount: Integer; safecall;
    function IsRightToLeft: WordBool; safecall;
    function LastError: WideString; safecall;
    function Send: WordBool; safecall;
    function UseRightToLeftReading: WordBool; safecall;
    function UseRightToLeftScrollBar: WordBool; safecall;
    function WasSuccessful: WordBool; safecall;
    procedure AddAttachment(const anAttachment: WideString); safecall;
    procedure AddCCRecipients(const aCCRecipient: WideString); safecall;
    procedure AddBCCRecipients(const aBCCRecipient: WideString); safecall;
    procedure AddLine(const aLine: WideString); safecall;
    procedure ClearAttachments; safecall;
    procedure ClearLines; safecall;
    procedure ClearAllRecipients; safecall;
    procedure InitiateAction; safecall;
    procedure NewMessage(const aFromAdress, aSubject: WideString); safecall;
    procedure NMSMTP1AttachmentNotFound(const Filename: WideString); safecall;
    procedure NMSMTP1AuthenticationFailed(var Handled: WordBool); safecall;
    procedure NMSMTP1ConnectionRequired(var Handled: WordBool); safecall;
    procedure NMSMTP1EncodeEnd(const Filename: WideString); safecall;
    procedure NMSMTP1EncodeStart(const Filename: WideString); safecall;
    procedure NMSMTP1HeaderIncomplete(var handled: WordBool; hiType: Integer);
      safecall;
    procedure NMSMTP1InvalidHost(var Handled: WordBool); safecall;
    procedure NMSMTP1MailListReturn(const MailAddress: WideString); safecall;
    procedure NMSMTP1RecipientNotFound(const Recipient: WideString); safecall;
    procedure Set_Cursor(Value: Smallint); safecall;
    procedure Set_DoubleBuffered(Value: WordBool); safecall;
    procedure Set_Enabled(Value: WordBool); safecall;
    procedure Set_Visible(Value: WordBool); safecall;
    procedure SetDebugMode; safecall;
    procedure SetFromAdress(const aFromAdress: WideString); safecall;
    procedure SetHost(const aHost: WideString); safecall;
    procedure SetSubject(const aSubject: WideString); safecall;
    procedure SetToAdress(const aToAdress: WideString); safecall;
    procedure SetUserID(const anUserID: WideString); safecall;
    procedure SetWorkMode; safecall;
    procedure SetSubType(aSubType: Integer); safecall;
  end;

implementation

uses ComObj;

{ TSmtpMailX }

procedure TSmtpMailX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
begin
  { TODO: Hier Eigenschaftsseiten definieren. Eigenschaftsseiten werden durch
     Aufruf von DefinePropertyPage mit der Klassen-ID der Eigenschaftsseite
       definiert. Beispiel: DefinePropertyPage(Class_SmtpMailXPage); }
end;

procedure TSmtpMailX.EventSinkChanged(const EventSink: IUnknown);
begin
  FEvents := EventSink as ISmtpMailXEvents;
end;

procedure TSmtpMailX.InitializeControl;
begin
  FDelphiControl := Control as TSmtpMailSS;
end;

function TSmtpMailX.DrawTextBiDiModeFlagsReadingOnly: Integer;
begin
  Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
end;

function TSmtpMailX.Get_Cursor: Smallint;
begin
  Result := Smallint(FDelphiControl.Cursor);
end;

function TSmtpMailX.Get_DoubleBuffered: WordBool;
begin
  Result := FDelphiControl.DoubleBuffered;
end;

function TSmtpMailX.Get_Enabled: WordBool;
begin
  Result := FDelphiControl.Enabled;
end;

function TSmtpMailX.Get_Visible: WordBool;
begin
  Result := FDelphiControl.Visible;
end;

function TSmtpMailX.Get_VisibleDockClientCount: Integer;
begin
  Result := FDelphiControl.VisibleDockClientCount;
end;

function TSmtpMailX.IsRightToLeft: WordBool;
begin
  Result := FDelphiControl.IsRightToLeft;
end;

function TSmtpMailX.LastError: WideString;
begin
  Result := FDelphiControl.LastError;
end;

function TSmtpMailX.Send: WordBool;
begin
  Result := FDelphiControl.Send;
end;

function TSmtpMailX.UseRightToLeftReading: WordBool;
begin
  Result := FDelphiControl.UseRightToLeftReading;
end;

function TSmtpMailX.UseRightToLeftScrollBar: WordBool;
begin
  Result := FDelphiControl.UseRightToLeftScrollBar;
end;

function TSmtpMailX.WasSuccessful: WordBool;
begin
  Result := FDelphiControl.WasSuccessful;
end;

procedure TSmtpMailX.AddAttachment(const anAttachment: WideString);
begin
  FDelphiControl.AddAttachment(anAttachment);
end;



procedure TSmtpMailX.AddCCRecipients(const aCCRecipient: WideString);
begin
  FDelphiControl.AddCCRecipients(aCCRecipient);
end;



procedure TSmtpMailX.AddBCCRecipients(const aBCCRecipient: WideString);
begin
  FDelphiControl.AddBCCRecipients(aBCCRecipient);
end;



procedure TSmtpMailX.AddLine(const aLine: WideString);
begin
  FDelphiControl.AddLine(aLine);
end;

procedure TSmtpMailX.ClearAttachments;
begin
  FDelphiControl.ClearAttachments;
end;

procedure TSmtpMailX.ClearLines;
begin
  FDelphiControl.ClearLines;
end;



procedure TSmtpMailX.ClearAllRecipients;
begin
  FDelphiControl.ClearAllRecipients;
end;



procedure TSmtpMailX.InitiateAction;
begin
  FDelphiControl.InitiateAction;
end;

procedure TSmtpMailX.NewMessage(const aFromAdress, aSubject: WideString);
begin
  FDelphiControl.NewMessage(aFromAdress, aSubject);
end;

procedure TSmtpMailX.NMSMTP1AttachmentNotFound(const Filename: WideString);
begin
  FDelphiControl.NMSMTP1AttachmentNotFound(Filename);
end;

procedure TSmtpMailX.NMSMTP1AuthenticationFailed(var Handled: WordBool);
begin

end;

procedure TSmtpMailX.NMSMTP1ConnectionRequired(var Handled: WordBool);
begin

end;

procedure TSmtpMailX.NMSMTP1EncodeEnd(const Filename: WideString);
begin
  FDelphiControl.NMSMTP1EncodeEnd(Filename);
end;

procedure TSmtpMailX.NMSMTP1EncodeStart(const Filename: WideString);
begin
  FDelphiControl.NMSMTP1EncodeStart(Filename);
end;

procedure TSmtpMailX.NMSMTP1HeaderIncomplete(var handled: WordBool;
  hiType: Integer);
begin

end;

procedure TSmtpMailX.NMSMTP1InvalidHost(var Handled: WordBool);
begin

end;

procedure TSmtpMailX.NMSMTP1MailListReturn(const MailAddress: WideString);
begin
  FDelphiControl.NMSMTP1MailListReturn(MailAddress);
end;

procedure TSmtpMailX.NMSMTP1RecipientNotFound(const Recipient: WideString);
begin
  FDelphiControl.NMSMTP1RecipientNotFound(Recipient);
end;

procedure TSmtpMailX.Set_Cursor(Value: Smallint);
begin
  FDelphiControl.Cursor := TCursor(Value);
end;

procedure TSmtpMailX.Set_DoubleBuffered(Value: WordBool);
begin
  FDelphiControl.DoubleBuffered := Value;
end;

procedure TSmtpMailX.Set_Enabled(Value: WordBool);
begin
  FDelphiControl.Enabled := Value;
end;

procedure TSmtpMailX.Set_Visible(Value: WordBool);
begin
  FDelphiControl.Visible := Value;
end;

procedure TSmtpMailX.SetDebugMode;
begin
  FDelphiControl.SetDebugMode;
end;

procedure TSmtpMailX.SetFromAdress(const aFromAdress: WideString);
begin
  FDelphiControl.SetFromAdress(aFromAdress);
end;

procedure TSmtpMailX.SetHost(const aHost: WideString);
begin
  FDelphiControl.SetHost(aHost);
end;

procedure TSmtpMailX.SetSubject(const aSubject: WideString);
begin
  FDelphiControl.SetSubject(aSubject);
end;

procedure TSmtpMailX.SetToAdress(const aToAdress: WideString);
begin
  FDelphiControl.SetToAdress(aToAdress);
end;

procedure TSmtpMailX.SetUserID(const anUserID: WideString);
begin
  FDelphiControl.SetUserID(anUserID);
end;

procedure TSmtpMailX.SetWorkMode;
begin
  FDelphiControl.SetWorkMode;
end;

procedure TSmtpMailX.SetSubType(aSubType: Integer);
begin
  FDelphiControl.SetSubType(aSubType);
end;

initialization
  TActiveXControlFactory.Create(
    ComServer,
    TSmtpMailX,
    TSmtpMailSS,
    Class_SmtpMailX,
    1,
    '{5E8F4C54-BB62-4903-B7FC-81BE3173DF58}',
    0,
    tmApartment);
end.
